/*
 * Copyright 2010 GP Software
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Mapping.java | Created on Apr 22, 2010
 */
package org.gp.gpetl.config;

/**
 * Value object for a mapping element
 *
 * @author Paul Augustine C. Mendoza
 * @since 1.0
 */
public class Mapping implements ConfigObject {

    /**
     * The column property
     */
    private String column;

    /**
     * The data type
     */
    private String type;

    /**
     * The default constructor
     */
    public Mapping() {
        super();
    }

    /**
     * The constructor with column and property names
     *
     * @param column the column name
     * @param type   the data type
     */
    public Mapping(String column, String type) {
        this.column = column;
        this.type = type;
    }

    /**
     * Gets the column name
     *
     * @return the column name
     */
    public String getColumn() {
        return column;
    }

    /**
     * Sets the column name
     *
     * @param column the column name to set
     */
    public void setColumn(String column) {
        this.column = column;
    }

    /**
     * Gets the data type
     *
     * @return the data type
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the data type
     *
     * @param type the data type
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Mapping mapping = (Mapping) o;

        if (column != null ?
                !column.equals(mapping.column) :
                mapping.column != null) return false;
        if (type != null ? !type.equals(mapping.type) : mapping.type != null)
            return false;

        return true;
    }

    /**
     * @see Object#hashCode()
     */
    @Override
    public int hashCode() {
        int result = column != null ? column.hashCode() : 0;
        result = 31 * result + (type != null ? type.hashCode() : 0);
        return result;
    }

    /**
     * @see Object#toString()
     */
    @Override
    public String toString() {
        return "Mapping{" +
                ", column='" + column + '\'' +
                ", type='" + type + '\'' +
                '}';
    }
}
